import axios from "axios";

const LC_SERVER_BASE_URL = "http://47.92.107.19:10085/";

export function getDistrictByCondition(params, success, fail) {
  axios
    .get(LC_SERVER_BASE_URL + "district/findDistrictByCondition", {
      params: params
    })
    .then(res => {
      if (res.data.success) {
        success(res.data.data);
      } else {
        if (typeof fail === "function") {
          fail(res.data);
        }
      }
    });
}

export function findHourlyStatisticsListByCondition(params, success, fail) {
  axios
    .post(
      LC_SERVER_BASE_URL + "stats/findHourlyStatisticsListByCondition",
      params
    )
    .then(res => {
      if (res.data.success) {
        success(res.data.data);
      } else {
        if (typeof fail === "function") {
          fail(res.data);
        }
      }
    });
}

export function getVelocityData(params, success, fail) {
  axios
    .post(LC_SERVER_BASE_URL + "velocity/findVelocityData", params)
    .then(res => {
      if (res.data.success) {
        success(res.data.data);
      } else {
        if (typeof fail === "function") {
          fail(res.data);
        }
      }
    });
}
